package com.guigu.service.impl.manufacture;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.manufacture.MManufactureMapper;
import com.guigu.mapper.manufacture.MProcedureMapper;
import com.guigu.pojo.manufacture.MProcedure;
import com.guigu.service.manufacture.MProcedureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

import java.util.ArrayList;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-06
 */
@Service
public class MProcedureServiceImpl extends ServiceImpl<MProcedureMapper, MProcedure> implements MProcedureService {

    @Autowired
    private MProcedureMapper mProcedureMapper;


    @Override
    public ArrayList<MProcedure> selectArrByParentId(Integer id) {
        QueryWrapper<MProcedure> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("PARENT_ID", id);
        queryWrapper.orderByAsc("DETAILS_NUMBER");
        ArrayList<MProcedure> mProcedures = (ArrayList<MProcedure>) mProcedureMapper.selectList(queryWrapper);
        return mProcedures;
    }

    @Override
    public List<MProcedure> getProcedureList(Integer parentId) {
        QueryWrapper<MProcedure> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("PARENT_ID",parentId);
        if(mProcedureMapper.selectList(queryWrapper)!=null){
            return mProcedureMapper.selectList(queryWrapper);
        }
        return null;
    }
}
